/* USER CODE BEGIN Header */
/**
 ******************************************************************************
 * @file           : main.h
 * @brief          : Header for main.c file.
 *                   This file contains the common defines of the application.
 ******************************************************************************
 * @attention
 *
 * Copyright (c) 2024 STMicroelectronics.
 * All rights reserved.
 *
 * This software is licensed under terms that can be found in the LICENSE file
 * in the root directory of this software component.
 * If no LICENSE file comes with this software, it is provided AS-IS.
 *
 ******************************************************************************
 */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C"
{
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f3xx_hal.h"

    /* Private includes ----------------------------------------------------------*/
    /* USER CODE BEGIN Includes */

    /* USER CODE END Includes */

    /* Exported types ------------------------------------------------------------*/
    /* USER CODE BEGIN ET */
    typedef enum
    {
        kOFF,
        kON
    } switch_state_t;

    typedef struct
    {
        uint8_t output_level;
    } rf_config_t;

    typedef struct
    {
        uint8_t init;
        rf_config_t config;
    } __ALIGNED(4) rf_flash_t;

    typedef struct
    {
        struct
        {
            switch_state_t output : 1;
            switch_state_t v_ctrl : 1;
        } setup;
        rf_flash_t flash;
        float detection;
        float temperature;
        float current;
        float input_voltage;
        float attenuation;
    } rf_source_t;
    /* USER CODE END ET */

    /* Exported constants --------------------------------------------------------*/
    /* USER CODE BEGIN EC */

    /* USER CODE END EC */

    /* Exported macro ------------------------------------------------------------*/
    /* USER CODE BEGIN EM */

    /* USER CODE END EM */

    /* Exported functions prototypes ---------------------------------------------*/
    void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define V28_EN_Pin GPIO_PIN_13
#define V28_EN_GPIO_Port GPIOC
#define RF_JB_ADC_Pin GPIO_PIN_0
#define RF_JB_ADC_GPIO_Port GPIOA
#define TEMP_ADC_Pin GPIO_PIN_1
#define TEMP_ADC_GPIO_Port GPIOA
#define CURR_ADC_Pin GPIO_PIN_2
#define CURR_ADC_GPIO_Port GPIOA
#define INPUT_ADC_Pin GPIO_PIN_3
#define INPUT_ADC_GPIO_Port GPIOA
#define SPI_NSS_Pin GPIO_PIN_15
#define SPI_NSS_GPIO_Port GPIOA
#define GPIO0_Pin GPIO_PIN_6
#define GPIO0_GPIO_Port GPIOB
#define GPIO2_Pin GPIO_PIN_7
#define GPIO2_GPIO_Port GPIOB
#define LED_Pin GPIO_PIN_8
#define LED_GPIO_Port GPIOB

/* USER CODE BEGIN Private defines */
#define FLASH_DEFAULT_INITIAL_VALUE 0x01
#define ATTENUATOR_MAX_VAL 35.0f

#define POWER_28V_ENABLE() HAL_GPIO_WritePin(V28_EN_GPIO_Port, V28_EN_Pin, GPIO_PIN_SET)
#define POWER_28V_DISABLE() HAL_GPIO_WritePin(V28_EN_GPIO_Port, V28_EN_Pin, GPIO_PIN_RESET)
#define LED_ON() HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET)
#define LED_OFF() HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET)
#define LED_TWINKLE() HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin)
    /* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
